﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Common.Utils;

//using PowerCreator.LMS.Logic.UserManager;
//using PowerCreator.LMS.Logic.Common;
//using PowerCreator.LMS.Model.Entity;

public partial class sysadmin_CountManager_VisitsSeach : PowerCreator.LMS.Web.Base.BasePage
{
    //ManagerLogin objManagerLogin = new ManagerLogin();
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!GetRole(Role.CountBrower))
        //{
        //    Script.ShowAndHistory("您没有访问量查询的权限!", -1);
        //    return;
        //}
        //if (!IsPostBack)
        //{
        //    string search = GetSearch();
        //    BinderPager(search);
        //    BinderGV(search, 1);
        //}
    }
    private string GetSearch()
    {
        String search = "";
        //if (!string.IsNullOrEmpty(txt_starttime.Text.Trim()) & !string.IsNullOrEmpty(txt_endtime.Text.Trim()) )
        //{
        //    if (PageValidate.IsDateTime(txt_starttime.Text.Trim()) & PageValidate.IsDateTime(txt_endtime.Text.Trim()))
        //    {
        //        search = string.Format(" and  logintime >='{0}' and logintime<='{1}'  ", txt_starttime.Text, txt_endtime.Text);
        //    }
        //    else
        //    {
        //        Script.Alert(this, "msg", "请指定合适的日期范围");
        //    }
            
        //}


        return search;
    }
    private void BinderPager(string search)
    {
        //int IsNull=0;
        //if (!string.IsNullOrEmpty(search))
        //{
        //    IsNull = 1;
        //}
        //AspNetPager1.RecordCount = objManagerLogin.GetUserLoginLogCount(search, IsNull);
        //AspNetPager1.PageSize = FBasePage.PageSize();
    }
    private void BinderGV(string search, int pageIndex)
    {
        //int IsNull = 0;
        //if (!string.IsNullOrEmpty(search))
        //{
        //    IsNull = 1;
        //}
        //DataTable dt = new DataTable();
        //dt = objManagerLogin.GetUserLoginLog(search,IsNull, pageIndex, FBasePage.PageSize());
        //dt.Columns.Remove("rowstat");
        //for (int i = 0; i < dt.Columns.Count-2; i++)
        //{
        //    for (int k = dt.Columns.Count-1; k >=1; k--)
        //    {
        //        if (PageValidate.IsInt(dt.Columns[k].ColumnName) & PageValidate.IsInt(dt.Columns[k-1].ColumnName))
        //        {
        //            if (int.Parse(dt.Columns[k].ColumnName) <int.Parse(dt.Columns[k-1].ColumnName))
        //            {

        //                dt.Columns[k].SetOrdinal(k-1);
        //                dt.Columns[k].SetOrdinal(k);
        //            }
        //        }
        //    }
        //}
        //for (int i = 0; i < dt.Columns.Count; i++)
        //{
        //    if (dt.Columns[i].ColumnName == "logintime")
        //    {
        //        dt.Columns[i].ColumnName = "日期";
        //    }
        //    else if (dt.Columns[i].ColumnName == "SumCount")
        //    {
        //        dt.Columns[i].ColumnName = "访问总量";
        //    }
        //    else
        //    {
        //        int newname=int.Parse(dt.Columns[i].ColumnName) + 1;
        //        dt.Columns[i].ColumnName =dt.Columns[i].ColumnName+"~"+ newname.ToString(); ;
        //    }

        //}
        //ViewState["dt"] = dt;
        //gv_LoginList.DataSource = dt;
        //gv_LoginList.DataBind();
    }
    private DataTable GetAllLst()
    {
        string search = GetSearch();
        int IsNull = 0;
        if (!string.IsNullOrEmpty(search))
        {
            IsNull = 1;
        }
        DataTable dt = new DataTable();

        //dt = objManagerLogin.GetUserLoginLog(search, IsNull, 1, objManagerLogin.GetUserLoginLogCount(search, IsNull));
        //dt.Columns.Remove("rowstat");
        //for (int i = 0; i < dt.Columns.Count - 2; i++)
        //{
        //    for (int k = dt.Columns.Count - 1; k >= 1; k--)
        //    {
        //        if (PageValidate.IsInt(dt.Columns[k].ColumnName) & PageValidate.IsInt(dt.Columns[k - 1].ColumnName))
        //        {
        //            if (int.Parse(dt.Columns[k].ColumnName) < int.Parse(dt.Columns[k - 1].ColumnName))
        //            {

        //                dt.Columns[k].SetOrdinal(k - 1);
        //                dt.Columns[k].SetOrdinal(k);
        //            }
        //        }
        //    }
        //}
        //for (int i = 0; i < dt.Columns.Count; i++)
        //{
        //    if (dt.Columns[i].ColumnName == "logintime")
        //    {
        //        dt.Columns[i].ColumnName = "日期";
        //    }
        //    else if (dt.Columns[i].ColumnName == "SumCount")
        //    {
        //        dt.Columns[i].ColumnName = "访问总量";
        //    }
        //    else
        //    {
        //        int newname = int.Parse(dt.Columns[i].ColumnName) + 1;
        //        dt.Columns[i].ColumnName = dt.Columns[i].ColumnName + "~" + newname.ToString(); ;
        //    }

        //}
        return dt;
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderPager(search);
        BinderGV(search, 1);
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderGV(search, AspNetPager1.CurrentPageIndex);
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        //DataTable dt = (DataTable)ViewState["dt"];

        //Excel objExcel = new Excel();
        //objExcel.ToExcel(dt, this.Page, "访问量统计", "访问量统计信息", "UserLoginLog");
    }
    protected void btnExport_All_Click(object sender, EventArgs e)
    {
        //DataTable dt = GetAllLst();

        //Excel objExcel = new Excel();
        //objExcel.ToExcel(dt, this.Page, "访问量统计", "访问量统计信息", "UserLoginLog");
    }
}
